import 'package:jinke/utils/date_format/date_util.dart';

class ProOpenFactorModel {
  String? code;
  String? parentCode;
  String? name;
  String? aliasName;
  String? codeType;
  String? codeTypeName;
  int? orderby;
  String? remark;
  String? isValid;
  String? createTime;
  String? updateTime;
  String? tenantId;

  ProOpenFactorModel({
    this.code,
    this.parentCode,
    this.name,
    this.aliasName,
    this.codeType,
    this.codeTypeName,
    this.orderby,
    this.remark,
    this.isValid,
    this.createTime,
    this.updateTime,
    this.tenantId,
  });

  factory ProOpenFactorModel.fromJson(Map<String, dynamic> json) {
    return ProOpenFactorModel(
      code: json['code'] as String?,
      parentCode: json['parentCode'] as String?,
      name: json['name'] as String?,
      aliasName: json['aliasName'] as String?,
      codeType: json['codeType'] as String?,
      codeTypeName: json['codeTypeName'] as String?,
      orderby: json['orderby'] as int?,
      remark: json['remark'] as String?,
      isValid: json['isValid'] as String?,
      createTime: json['createTime'] as String?,
      updateTime: json['updateTime'] as String?,
      tenantId: json['tenantId'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'code': code,
        'parentCode': parentCode,
        'name': name,
        'aliasName': aliasName,
        'codeType': codeType,
        'codeTypeName': codeTypeName,
        'orderby': orderby,
        'remark': remark,
        'isValid': isValid,
        'createTime': createTime,
        'updateTime': updateTime,
        'tenantId': tenantId,
      };
  Map<String, dynamic> toParm() => {
        'phaseCode': code,
        'phaseCompleteTime': createTime ?? '',
        'phaseLimitTime': createTime != null ? '1' : '',
        'phaseName': name,
        'phaseOrder': orderby,
        'required': code == 'PROJECT_PHASE_1',
      };
}
